package com.order.convert;

import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

import com.order.entity.Goods;

public class GoodsConvert extends StrutsTypeConverter {

	@SuppressWarnings("rawtypes")
	@Override
	public Object convertFromString(Map arg0, String[] infos, Class arg2) {
		String[] info = infos[0].split(",");
		Goods goods = new Goods();
		goods.setId(Integer.parseInt(info[0]));
		goods.setName(info[1]);
		goods.setPrice(Double.parseDouble(info[2]));
		return goods;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public String convertToString(Map arg0, Object arg1) {
		return arg1.toString();
	}

}
